home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1987 / 06 / bbs.l10 < prev    next >
Text File  |  1987-05-05  |  1KB  |  59 lines

  1. Listing Ten
  2.  
  3. usage
  4.  
  5.  
  6.  
  7.     # print headings to report file
  8.  
  9. 1    echo "User      Date     Login     Logout" >usage.temp
  10. 2    echo "---------------------------------------------" >>usage.temp
  11. 3    echo " " >>usage.temp
  12.  
  13.     # get a log in record from /etc/wtmp for remote users on device ph1
  14.  
  15. 4    who /etc/wtmp | grep ph1 >temp1
  16.  
  17.     # get the user name
  18.  
  19. 5    cut -f1 -d" " temp1 >temp2
  20.  
  21.     # get the log in date and time
  22.  
  23. 6    cut -c25-36 temp1 >temp3
  24.  
  25.     # get log out record from /etc/wtmp and extract the log out time
  26.  
  27. 7    who -d /etc/wtmp | grep ph1 | grep -v LOGIN | grep -v rc | cut -c32-36 >temp4
  28.  
  29.     # paste together for the report
  30.  
  31. 8    paste temp2 temp3 temp4 >>usage.temp
  32.  
  33.     # print the report
  34.  
  35. 9    pr usage.temp >usage.summary
  36.  
  37.     # remove temporary files
  38.  
  39. 10    rm temp1
  40. 11    rm temp2
  41. 12    rm temp3
  42. 13    rm temp4
  43. 14    rm usage.temp
  44.  
  45.     # format the BBS command use log for output and purge the log file
  46.  
  47. 15    pr /u/bbs/log.file >log.summary
  48. 16    > /u/bbs/log.file
  49.  
  50.     # clean out /etc/wtmp
  51.  
  52. 17    > /etc/wtmp
  53.  
  54.     # send both reports to the printer
  55.  
  56. 18    lp usage.summary
  57. 19    lp log.summary
  58.  
  59.